package com.easidea.tim.flex.util
{
	import mx.formatters.DateFormatter;
	
	public class DateUtil
	{
		public static function string2Date(string : String) : Date {
            if (string == null || string =="") return null;
			var year:String = string.substr(0,4);
			var month:int = parseInt(string.substr(5,2))-1;
			var day:int = parseInt(string.substr(8,2));
			var h:int = parseInt(string.substr(11,2));
			var m:int = parseInt(string.substr(14,2));
			var s:int = parseInt(string.substr(17,2));
			var date : Date = new Date(year,month,day,h,m,s,0);
			return date;
		}
		public static function compareDate(sDate:String,eDate:String):Boolean {
				var myPattern1:RegExp=/-|:| /g;
              	sDate=sDate.replace(myPattern1,''); 
                eDate=eDate.replace(myPattern1,''); 
               if(int(sDate) > int(eDate)) {
               	return true;
               }			
               return false;
		}
		public static function date2String(date:Date):String {
			var df:DateFormatter = new DateFormatter();
			df.formatString = "YYYY-MM-DD";
			return df.format(date);
		}
	}
}